﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SS2TC.Speech
{
    public class WaveFormat
    {
        public WaveFormat()
        {
            Channels = Channels.Mono;
            SamplingRate = 8000;
            BitsPerSample = BitsPerSample.LowQuality;
            WaveFormatTag = WaveFormatTag.WAVE_FORMAT_PCM;
        }

        public Channels Channels
        {
            get; //  1 = mono, 2 = stereo
            set;
        }

        /// <summary>
        /// Samples per second.
        /// </summary>
        public uint SamplingRate
        {
            get;
            set;
        }

        /// <summary>
        /// Bits per sample.
        /// </summary>
        public BitsPerSample BitsPerSample
        {
            get;
            set;
        }

        public short BlockSize
        {
            //  = Channels * BitsPerSample / 8
            get { return Convert.ToInt16((byte) BitsPerSample / 8); }
        }

        public uint AverageBytesPerSecond
        {
            //  = SamplesPerSec * Channels * BitsPerSample / 8
            get { return Convert.ToUInt32(SamplingRate * (byte) BitsPerSample / 8); }
        }

        public WaveFormatTag WaveFormatTag
        {
            get;
            set;
        }
    }

    public enum WaveFormatTag : short
    {
        //  Pulse coded modulated and uncompressed
        WAVE_FORMAT_PCM = 0x0001
    }

    public enum BitsPerSample : byte
    {
        LowQuality = 8,
        HighQuality = 16
    }

    public enum Channels : byte
    {
        Mono = 1,
        Stereo = 2
    }
}
